/**
 *  预警预报应用深化-周期性分析-大气污染物周变化规律
 *  Created by lins on 2018/7/17.
 */
'use strict';
angular.module("MetronicApp").directive('weekLine', function () {
    return {
        scope: {
            id: "@",
            data: "="
        },
        restrict: 'EA',
        template: '',
        replace: true,
        link: function ($scope, element, attrs, controller) {
            function getOption(data) {
                var number=[]
                for(var i=1;i<52;i++){
                    number.push(i);
                }
                var option = {
                    title : {
                        text: '大气污染物周变化规律',
                        x:'center',
                        textStyle:{  //标题文字设置
                            fontSize: '20',
                            fontWeight: 'bold',
                            color: '#5AB1EF'
                        }
                    },

                    tooltip: {
                        trigger: 'axis'
                    },
                    legend: {
                        data:['SO2','NO2','PM10','PM2.5','CO','O3'],
                        x : 'center',
                        y : 'bottom'
                    },
                    xAxis: [{

                        axisLabel:{
                            interval:1,
                        },
                        data:number
                    }],


                    yAxis: [{

                        min:0,
                        max:80,
                        interval:20,
                    }],

                    series : [
                        {
                            name:'SO2',
                            type:'line',
                            smooth: 0.4,
                            color:'#2EC7C9',
                            data:[15, 45, 23, 8,40, 34,3,12,55, 45, 23, 54,40, 75,3,12,55, 45, 23, 54,3, 75,72,7,55, 45, 4, 54,40,23,34,15, 8, 23, 54,40, 75,72,12,55, 45, 23, 54,40, 75,15, 45, 23, 8,40, 34,3,12]
                        },
                        {
                            name:'NO2',
                            type:'line',
                            smooth: 0.4,
                            color:'#B6A2DE',
                            data:[24,55,67,32,56,78,34,43,24,55,67,32,56,78,34,43,24,55,67,32,56,78,34,43,24,55,67,32,56,78,34,67,32,56,78,34,43,24,55,67,32,56,78,34,43,24,55,67,32,56,78,34]
                        },
                        {
                            name:'PM10',
                            type:'line',
                            smooth: 0.4,
                            color:'#5AB1EF',
                            data:[76,43,54,21,45,76,66,36,76,43,54,21,45,76,66,5,76,43,54,21,45,5,66,36,76,43,54,21,45,76,66,3,21,45,76,66,4,76,43,54,21,45,76,6,36,76,43,54,21,45,76,66]
                        },
                        {
                            name:'PM2.5',
                            type:'line',
                            smooth: 0.4,
                            color:'#FFB980',
                            data:[35,65,45,56,76,23,45,54,35,65,45,56,76,23,45,54,35,65,45,56,76,23,3,54,35,65,45,56,4,23,45,6,56,76,23,9,54,35,65,45,56,6,23,45,54,35,65,45,56,76,23,45]
                        },
                        {
                            name:'CO',
                            type:'line',
                            smooth: 0.4,
                            color:'#D8807A',
                            data:[34,43,55,63,32,39,56,43,35,65,45,56,76,23,45,54,35,4,45,56,76,2,45,54,35,65,45,12,76,23,45,45,56,76,23,45,54,35,65,45,56,76,23,45,54,35,65,45,56,76,23,45]
                        },
                        {
                            name:'O3',
                            type:'line',
                            smooth: 0.4,
                            color:'#8D98B3',
                            data:[76,43,54,79,34,58,70,32,76,43,54,79,34,58,70,32,76,43,54,79,34,58,70,32,2,43,54,79,34,58,70,54,3,34,58,70,32,76,5,54,79,34,58,70,32,76,43,54,79,34,58,70]
                        }
                    ]
                };
                return option;
            }

            var myChart = echarts.init(document.getElementById('weekChangeRugular'), 'macarons');
            myChart.setOption(getOption($scope.data));

            $scope.$watch('data', function (newVal, oldVal) {
                myChart.setOption(getOption(newVal));
            });
        }
    };
});
